# coding=UTF-8
from matplotlib import pyplot as plt
import cv2


# 灰度图显示
def yulan(image):
    plt.imshow(image, cmap='gray', interpolation='bicubic')
    plt.xticks([]), plt.yticks([])
    plt.show()


# 垂直画直方图
def paintVerBar(x, y):
    plt.bar(x, y, alpha=.5, color='b')
    plt.show()


# 水平直方图
def paintHorBar(x, y):
    plt.barh(x, y, alpha=.5, color='b', linewidth=1)
    plt.show()


# 在原始图片上画轮廓
# image numpy图片
# srcpoint 起始点(元组类型)
#
def paintLine(image, srcpoint, topoint):
    img = cv2.line(image, srcpoint, topoint, (0, 255, 0), 3)
    yulan(img)


# 在原始图片上画矩形轮廓

def paintRectange(image, srcpoint, topoint):
    img = cv2.rectangle(image, srcpoint, topoint, (0, 255, 127), 3)
    yulan(img)


# image
def paintOutLineOfChr(image, horline, verline):
    for i in range (len(verline)):
        vpoint=verline[i]
        a=vpoint[0]
        b=horline[0]
        srcpoint = (vpoint[0], horline[0])
        topoint = (vpoint[1], horline[1])
        image = cv2.rectangle(image, srcpoint, topoint, (0, 255, 127), 2)
    yulan(image)
